package com.lufan.util;

import com.lufan.constant.DefaultConstants;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;

import java.io.IOException;

public class HttpUtil {

    public static Response sendGet(OkHttpClient client, String url) throws IOException {
        Request.Builder requestBuilder = new Request.Builder()
                .url(url)
                .header("User-Agent", "MyApp/1.0")
                .header("Accept", "application/json")
                .header("referer", DefaultConstants.headers.get("Referer"));
        String sessdata = UserContext.getSessdata();

        if (sessdata != null) {
            requestBuilder.header("Cookie", "SESSDATA=" + sessdata);
        }

        Request request = requestBuilder.build();

        return client.newCall(request).execute();
    }

}
